﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using EMANIFEST.Dtos;

namespace TestSaveRecord
{
    /// <summary>
    /// Summary description for TestCrewEffect
    /// </summary>
    [TestClass]
    public class TestCrewEffectRecord
    {
        eManifestService.EmanifestServiceClient client = new eManifestService.EmanifestServiceClient();

        public TestCrewEffectRecord()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void TestInsertCrewEffect()
        {
            try
            {
                CrewEffectDeclarationDto cre = new CrewEffectDeclarationDto();
                cre.CrewEffectDeclarationId = new Guid("35553AEB-F238-4550-8E58-D2FFE041937D");
                cre.DutyPackage = "May tinh xach tay";
                cre.FullName = "Nguyen Tien Tan";
                cre.CreatedDate = DateTime.Now;
                cre.Rank = "Thuyen Truong update";
                cre.DocumentId = new Guid("DAB27624-2270-4C40-A977-8856C4A8388A");
                cre.CreaterId = new Guid("93ec220c-5b57-4dac-88aa-9a314e1a7424");

                client.SaveCrewEffectDeclarationRecord(cre);
                CrewEffectDeclarationDto cedto = client.GetCrewEffectDeclarationById(cre.CrewEffectDeclarationId);
                if (cedto != null)
                    Console.WriteLine("Cap nhat thanh cong");
                else
                    Console.WriteLine("cap nhat that bai");
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.InnerException.Message);
            }
        }


        [TestMethod]
        public void TestUpdateCrewEffect()
        {
            try
            {
                CrewEffectDeclarationDto cre = new CrewEffectDeclarationDto();
                cre.CrewEffectDeclarationId = new Guid("35553AEB-F238-4550-8E58-D2FFE041937D");
                cre.DutyPackage = "May tinh xach tay";
                cre.FullName = "Nguyen Tien Tan update";
                cre.CreatedDate = DateTime.Now;
                cre.Rank = "Thuyen Truong update";
                cre.DocumentId = new Guid("DAB27624-2270-4C40-A977-8856C4A8388A");
                cre.CreaterId = new Guid("93ec220c-5b57-4dac-88aa-9a314e1a7424");

                eManifestService.EmanifestServiceClient client = new eManifestService.EmanifestServiceClient();
                client.SaveCrewEffectDeclarationRecord(cre);

                CrewEffectDeclarationDto cedto = client.GetCrewEffectDeclarationById(cre.CrewEffectDeclarationId);
                if (cedto != null)
                    Console.WriteLine("Cap nhat thanh cong");
                else
                    Console.WriteLine("cap nhat that bai");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException.Message);
            }
        }

        [TestMethod]
        public void TestDeleteCrewEffect()
        {
            try
            {
                client.DeleteCrewEffectDeclarationById(new Guid("35553AEB-F238-4550-8E58-D2FFE041937D"));

                CrewEffectDeclarationDto cedto = client.GetCrewEffectDeclarationById(new Guid("35553AEB-F238-4550-8E58-D2FFE041937D"));
                if (cedto == null)
                    Console.WriteLine("Cap nhat thanh cong");
                else
                    Console.WriteLine("cap nhat that bai");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException.Message);
            }
        }


    }
}
